﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;
using System.Net;

namespace iTunesFastForward
{
    class AlbumCover
    {

        public string ImageURLTiny { get; set; }
        public string ImageURLMedium { get; set; }
        public string ImageURLBig { get; set; }

        public Image ImageTiny { get; set; }
        public Image ImageMedium { get; set; }
        public Image ImageBig { get; set; }

        public string Artist { get; set; }
        public string Album { get; set; }
        public string Year { get; set; }

        public void FetchCovers(bool fetchBigImage)
        {
            //if (!string.IsNullOrEmpty(ImageURLTiny) && ImageTiny == null)
            //    ImageTiny = GetImageFromUrl(ImageURLTiny);
            if (!string.IsNullOrEmpty(ImageURLMedium) && ImageMedium == null)
                ImageMedium = GetImageFromUrl(ImageURLMedium);
            if (fetchBigImage && !string.IsNullOrEmpty(ImageURLBig) && ImageBig == null)
                ImageBig = GetImageFromUrl(ImageURLBig);
        }

        private Image GetImageFromUrl(string url)
        {
            return Image.FromStream(WebRequest.Create(url).GetResponse().GetResponseStream());
        }

    }
}
